package com.zxl.placeholderParse;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * 正则表达式测试
 */
public class RegTest {
    
    public static void test1() {
        String str = "${adw}<span class=\"redfont\">${payTotal}</span>";
        String regex = "\\$\\{[a-zA-Z]+\\}";
        Pattern pattern = Pattern.compile(regex);
        Matcher matcher = pattern.matcher(str);
        while (matcher.find()) {
            System.out.println(matcher.group());
        };
    }
    
    public static void test2() {
        String str = "<foreach collection=\"${testList}\" var=\" asd\">";
        String regex = "([a-zA-Z]+)\\=\"(\\p{Blank}*[\\w]+\\p{Blank}*)\"";
        Pattern pattern = Pattern.compile(regex);
        Matcher matcher = pattern.matcher(str);
        while (matcher.find()) {
            System.out.println(matcher.group(0));
            System.out.println(matcher.group(1));
            System.out.println(matcher.group(2));
        };
    }
    
    public static void main(String[] args) {
        test2();
    }
}
